package com.wkbb.sports.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.wkbb.common.handler.JsonUtil;
import com.wkbb.common.utils.DateUtil;
import com.wkbb.common.utils.DateUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

/**
 * 学生擂台赛
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class StudentArena implements Serializable {

    @ApiModelProperty(value = "发起人")
    private String originatorName;
    @ApiModelProperty(value = "比赛方式 1线上 2线下")
    private Integer way;
    @ApiModelProperty(value = "经度")
    private Double longitude;
    @ApiModelProperty(value = "纬度")
    private Double latitude;
    @ApiModelProperty(value = "赛事具体地址")
    private String address;
    @ApiModelProperty(value = "距离（km）")
    private Double distance;

    @ApiModelProperty(value = "邀请码")
    private String inviteCode;
    @ApiModelProperty(value = "展示图")
    private String logo;
    @ApiModelProperty(value = "生成邀请码")
    private Boolean generateInviteCode;
    @ApiModelProperty(value = "编号")
    private Long id;
    @ApiModelProperty(value = "学生编号")
    private Long studentId;
    @ApiModelProperty(value = "是否需要实名认证")
    private Boolean faceRecognition;
    @ApiModelProperty(value = "创建者")
    private String createStudentName;
    @ApiModelProperty(value = "名称")
    private String name;
    @ApiModelProperty(value = "年级ID列表（,号隔开）")
    private String gradeIds;
    @ApiModelProperty(value = "年级名称（,号隔开）")
    private String gradeNames;
    @ApiModelProperty(value = "类型(1个人赛 2团队赛 3亲子赛)")
    private Integer type;
    @ApiModelProperty(value = "跳绳类型1速度跳绳 2花样跳绳")
    private Integer jumpType;
    @ApiModelProperty(value = "模式(1限时 2限数 3自由模式)")
    private Integer modelType;
    @ApiModelProperty(value = "是否官方发布")
    private Boolean official;
//    @ApiModelProperty(value = "统计方式(1取最优成绩 2取累计成绩)")
//    private Integer statisticalType;
    @ApiModelProperty(value = "要求时间（秒）")
    private Integer trainRequire;
    @ApiModelProperty(value = "挑战人数 0不限")
    private Integer challengeNum;
    @ApiModelProperty(value = "挑战团队数量 0不限",required = false)
    private Integer challengeTeamNum;
    @ApiModelProperty(value = "挑战次数 0不限",required = false)
    private Integer challengeCount;
    @ApiModelProperty(value = "发布到 1全民 2学校 3班级")
    private Integer showArea;
    @ApiModelProperty(value = "擂主名称")
    private String championName;
    @ApiModelProperty(value = "擂主成绩")
    private Double championAchievement;
    @ApiModelProperty(value = "参赛选手人数")
    private Integer playerCount;
    @ApiModelProperty(value = "开始时间")
    private Date startTime;
    @ApiModelProperty(value = "结束时间")
    private Date endTime;
    @ApiModelProperty(value = "创建时间")
    private Date createTime;
    @ApiModelProperty(value = "我的参赛成绩")
    private StudentArenaTrain train;
    @ApiModelProperty(value = "擂台介绍（奖励说明）")
    private String introduce;

    //当前状态 0未开始 1进行中 2已结束
    @ApiModelProperty(value = "当前状态 0未开始 1进行中 2已结束")
    private Integer state;
//    public int getState(){
//        if (startTime != null && endTime != null){
//            long currentTimeMillis = System.currentTimeMillis();
//            if (currentTimeMillis > startTime.getTime()){
//                if (currentTimeMillis < endTime.getTime()){
//                    return 1;
//                }else{
//                    return 2;
//                }
//            }
//        }
//        return 0;
//    }

    public static void main(String[] args) {
        StudentArena info = new StudentArena();
        info.setName("擂台名称");
        info.setGradeIds("45,46");
        info.setGradeNames("六年级,七年级");
        info.setType(2);
        info.setModelType(1);
        info.setTrainRequire(60);
        info.setChallengeNum(10);
        info.setChallengeTeamNum(10);
        info.setChallengeCount(0);
        Calendar gCal = Calendar.getInstance();
        gCal.add(GregorianCalendar.DATE, 2);
        info.setStartTime(new Date());
        info.setEndTime(gCal.getTime());
        info.setShowArea(2);
        info.setStudentId(1272188L);
        System.out.println(JsonUtil.objectToJson(info));
    }
}